package zhongbo.java.air.monitor.web;//package zhongbo.java.air.monitor.web;
//
//import cn.hutool.core.date.DateUtil;
//import cn.hutool.core.util.StrUtil;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.data.domain.Page;
//import org.springframework.http.ResponseEntity;
//import org.springframework.web.bind.annotation.*;
//import zhongbo.java.air.common.vo.ResultVo;
//import zhongbo.java.air.monitor.model.FlightActivityDaily;
//import zhongbo.java.air.monitor.service.IFlightActivityDailyService;
//
//import javax.validation.Valid;
//import java.util.List;
//
///**
// * 说明：
// *
// * @author 钟波dellNotebook
// * @since 2025年04月08日 星期二 03:35:26
// */
//@RestController
//@RequestMapping("flightPath")
//@Api(tags = "航迹数据接口")
//public class FlightActivityDailyController {
//
//    private static final Logger logger = LoggerFactory.getLogger(FlightActivityDailyController.class);
//
//    @Autowired
//    private IFlightActivityDailyService flightActivityDailyService;
//
//    @ApiOperation("(老师)查询当天分组统计结果")
//    @GetMapping("getDailyStats")
//    public ResultVo<List<FlightActivityDaily>> getDailyStats(String date) {
//        // 如果不传, 则默认查当天的统计结果
//        if (StrUtil.isBlank(date)) {
//            date = DateUtil.today();
//        }
//        List<FlightActivityDaily> dailyList = flightActivityDailyService.selectDailyStats(date);
//        return ResultVo.ok(dailyList);
//    }
//    /*
//    * 根据date 查询当天的统计结果
//    * */
//    @ApiOperation("根据date查询当天分组统计结果")
//    @GetMapping("getDailyStatsByDate")
//    public ResultVo<List<FlightActivityDaily>> getDailyStatsByDate(
//            @RequestParam(value = "date") String date
//    ) {
//        // 如果不传, 则默认查当天的统计结果
//        if (StrUtil.isBlank(date)) {
//            date = DateUtil.today();
//        }
//        List<FlightActivityDaily> dailyList = flightActivityDailyService.getDailyStats(date);
//        return ResultVo.ok(dailyList);
//    }
//
//    @ApiOperation("根据icaoCode，date查询当天的统计结果")
//    @GetMapping("selectByIcaoAndDate")
//    public ResultVo<List<FlightActivityDaily>> selectByIcaoAndDate(@RequestParam String icaoCode, @RequestParam String date){
//        if (StrUtil.isBlank(icaoCode) || StrUtil.isBlank(date)){
//            throw new RuntimeException("icaoCode和date参数必须填写!示例: 2025-04-08");
//        }
//        // 确保传入的 date 格式与数据库中的格式一致
//        java.util.Date parsedDate = DateUtil.parseDate(date);
//        if (parsedDate == null) {
//            throw new RuntimeException("date参数格式不正确!示例: 2025-04-08");
//        }
//        List<FlightActivityDaily> flightActivityDaily = flightActivityDailyService.selectByIcaoAndDate(icaoCode, parsedDate);
//        if (flightActivityDaily.isEmpty()) {
//            logger.warn("No data found for icaoCode: {} and date: {}", icaoCode, date);
//        }
//        return ResultVo.ok(flightActivityDaily);
//    }
//
//    /**
//     * 分页查询
//     *
//     * @param pageNum 页码
//     * @param pageSize 每页大小
//     * @return 查询结果
//     */
//    @GetMapping
//    @ApiOperation(value = "分页查询", notes = "根据查询消息分页返回列表")
//    public Page<FlightActivityDaily> queryByPage(@RequestParam Integer pageNum, @RequestParam Integer pageSize){
//        return flightActivityDailyService.queryByPage(pageNum, pageSize);
//    }
//
//    /**
//     * 通过主键查询单条数据
//     *
//     * @param id 主键
//     * @return 单条数据
//     */
//    @GetMapping("{id}")
//    @ApiOperation(value = "用户查询", notes = "通过主键查询单条数据")
//    public ResponseEntity<FlightActivityDaily> queryById(@PathVariable("id")  String id) throws Exception {
//        return ResponseEntity.ok(this.flightActivityDailyService.queryById(id));
//    }
//    /**
//     * 新增数据
//     *
//     * @param flightActivityDaily 实体
//     * @return 新增结果
//     */
//    @PostMapping
//    @ApiOperation(value = "用户新增", notes = "新增数据")
//    public ResponseEntity<FlightActivityDaily> insert(@RequestBody @Valid FlightActivityDaily flightActivityDaily) throws Exception {
//        return ResponseEntity.ok(this.flightActivityDailyService.insert(flightActivityDaily));
//    }
//    /**
//     * 修改数据
//     *
//     * @param flightActivityDaily 实体
//     * @return 编辑结果
//     */
//    @PutMapping
//    @ApiOperation(value = "用户修改", notes = "修改数据")
//    public ResponseEntity<FlightActivityDaily> update(@RequestBody @Valid FlightActivityDaily flightActivityDaily) throws Exception {
//        return ResponseEntity.ok(this.flightActivityDailyService.update(flightActivityDaily));
//    }
//    /**
//     * 删除数据
//     *
//     * @param id 主键
//     * @return 删除是否成功
//     */
//    @DeleteMapping("{id}")
//    @ApiOperation(value = "用户删除", notes = "删除数据")
//    public ResponseEntity<Boolean> deleteById(@PathVariable("id") @Valid  String id) throws Exception {
//        return ResponseEntity.ok(this.flightActivityDailyService.deleteById(id));
//    }
//
//}



import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;
import zhongbo.java.air.common.vo.PageVo;
import zhongbo.java.air.common.vo.ResultVo;
import zhongbo.java.air.monitor.model.AirAlertLog;
import zhongbo.java.air.monitor.model.FlightActivityDaily;
import zhongbo.java.air.monitor.service.IFlightActivityDailyService;

import java.util.List;

/**
 * 说明：
 *
 * @author 钟波dellNotebook
 * @since 2025年04月08日 星期二 03:35:26
 */
@RestController
@RequestMapping("flightActivityDaily")
@Api(tags = "每日航迹活动信息接口")
public class FlightActivityDailyController {

    @Autowired
    private IFlightActivityDailyService<FlightActivityDaily> flightActivityDailyService;

    @ApiOperation("查询当天航迹活动结果")
    @GetMapping("getDailyStats")
    public ResultVo<List<FlightActivityDaily>> getDailyStats(String date) {
        // 如果不传, 则默认查当天的统计结果
        if (StrUtil.isBlank(date)) {
            date = DateUtil.today();
        }
        List<FlightActivityDaily> dailyList = flightActivityDailyService.getDailyStats(date);
        return ResultVo.ok(dailyList);
    }

    // to//do 今日周二待做, 标准crud接口(包括分页)

    @PostMapping("add")
    @ApiOperation("添加")
    ResultVo<FlightActivityDaily> add(@RequestBody FlightActivityDaily entity) {
        FlightActivityDaily flightActivityDaily = flightActivityDailyService.add(entity);
        return ResultVo.ok(flightActivityDaily);
    }

    @GetMapping("delete")
    @ApiOperation("删除")
    ResultVo<String> delete(String entityId) {
        String delete = String.valueOf(flightActivityDailyService.delete(entityId));
        return ResultVo.ok(delete);
    }

    @PostMapping("edit")
    @ApiOperation("修改")
    ResultVo<FlightActivityDaily> edit(@RequestBody FlightActivityDaily edit) {
        FlightActivityDaily flightActivityDaily = flightActivityDailyService.edit(edit);
        return ResultVo.ok(flightActivityDaily);
    }

    @GetMapping("findOne")
    @ApiOperation("查询一条")
    ResultVo<FlightActivityDaily> findOne(String entityId) {
        FlightActivityDaily flightActivityDaily = flightActivityDailyService.findOne(entityId);
        return ResultVo.ok(flightActivityDaily);
    }

//    @GetMapping("findPage")
//    @ApiOperation("分页查询列表")
//    ResultVo<PageVo<FlightActivityDaily>> findPage(Integer page, Integer pageSize
//            , String icao, String startDate, String endDate
//            , String keyword, String fields
//            , String oderByField, Boolean orderByAsc) {
//        PageVo<FlightActivityDaily> pageVo = flightActivityDailyService.findPage(page, pageSize
//                , icao, startDate, endDate
//                , keyword, fields, oderByField, orderByAsc);
//        return ResultVo.ok(pageVo);
//    }

    @GetMapping("findPage")
    @ApiOperation("分页查询列表")
    ResultVo<PageVo<FlightActivityDaily>> findPage(Integer page, Integer pageSize
            , String keyword, String fields
            , String oderByField, Boolean orderByAsc) {
        PageVo<FlightActivityDaily> pageVo = flightActivityDailyService.findPage(page, pageSize, keyword, fields, oderByField, orderByAsc);
        return ResultVo.ok(pageVo);
    }
}

